from django.db import models

# Create your models here.
from db.basemodel import BaseBean
from django.contrib.auth.models import AbstractUser

class UserBean(AbstractUser, BaseBean):

    class Meta:
        # 确定表名
        db_table = "table_user"
        # 中文名称
        verbose_name = "用户名"
        # 模型的复数形式(即自动在模型后添加一个s)
        verbose_name_plural = verbose_name
# 地址模型类
class AddressBean(BaseBean):
    # 地址ID
    # 收件人
    receiver = models.CharField(max_length=20, verbose_name="收件人")
    # 收件地址
    address = models.CharField(max_length=300, verbose_name="收件地址")
    # 邮编号码
    post_code = models.CharField(max_length=6, null=True, verbose_name="邮编号码")
    # 联系方式
    phone_num = models.CharField(max_length=11, verbose_name="联系方式")
    # 是否为默认地址
    is_default = models.BooleanField(default=False, verbose_name="是否为默认地址")
    # 用户ID
    user = models.ForeignKey("UserBean", verbose_name="所属账户")
    class Meta:
        # 表名
        db_table = "table_address"
        # 中文名称
        verbose_name = "地址"
        # 模型的复数形式
        verbose_name_plural = verbose_name